Skip to content

feat(messaging): add message bus pattern#373

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/message-bus-pattern
May 26, 2026
Merged

feat(messaging): add message bus pattern#373
JerrettDavis merged 1 commit into
mainfrom
feature/message-bus-pattern

Conversation

@JerrettDavis

Copy link
Copy Markdown
Owner

Summary

  • add typed MessageBus over MessageChannel topic subscribers
  • add GenerateMessageBus/MessageBusRoute source generator, diagnostics, and release tracking
  • add order message bus DI example, TinyBDD coverage, catalog entries, docs, and BenchmarkDotNet rows

Validation

  • dotnet build PatternKit.slnx --configuration Release --no-restore -m:1
  • dotnet test test/PatternKit.Tests/PatternKit.Tests.csproj --configuration Release --no-build --logger "console;verbosity=minimal" -p:TestTfmsInParallel=false
  • dotnet test test/PatternKit.Generators.Tests/PatternKit.Generators.Tests.csproj --configuration Release --no-build --logger "console;verbosity=minimal" -p:TestTfmsInParallel=false
  • dotnet test test/PatternKit.Examples.Tests/PatternKit.Examples.Tests.csproj --configuration Release --no-build --logger "console;verbosity=minimal" -p:TestTfmsInParallel=false
  • dotnet run -c Release --framework net10.0 --project benchmarks/PatternKit.Benchmarks -- --filter MessageBus --artifacts artifacts/benchmarks-messagebus --join

Closes #363 for the Message Bus slice. Tracks Messaging Bridge in #372.

Copilot AI review requested due to automatic review settings May 26, 2026 18:25
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@JerrettDavis JerrettDavis changed the title Add Message Bus enterprise integration pattern feat(messaging): add message bus pattern May 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    1 files      1 suites   2m 40s ⏱️
1 023 tests 1 023 ✅ 0 💤 0 ❌
1 028 runs  1 028 ✅ 0 💤 0 ❌

Results for commit 3fc9808.

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.67442% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.62%. Comparing base (edae6cb) to head (3fc9808).

Files with missing lines Patch % Lines
...tternKit.Core/Messaging/Channels/MessageChannel.cs 93.22% 4 Missing ⚠️
...ernKit.Generators/Messaging/MessageBusGenerator.cs 98.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #373      +/-   ##
==========================================
+ Coverage   89.59%   95.62%   +6.02%     
==========================================
  Files         500      502       +2     
  Lines       40966    41181     +215     
  Branches     5913     5948      +35     
==========================================
+ Hits        36705    39378    +2673     
+ Misses       1942     1803     -139     
+ Partials     2319        0    -2319     
Flag Coverage Δ
unittests 95.62% <97.67%> (+6.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/26/2026 - 18:31:02
  Coverage date: 05/26/2026 - 18:28:55 - 05/26/2026 - 18:30:51
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1522
  Files: 613
  Line coverage: 94.5%
  Covered lines: 40389
  Uncovered lines: 2312
  Coverable lines: 42701
  Total lines: 93623
  Branch coverage: 75.6% (11918 of 15749)
  Covered branches: 11918
  Total branches: 15749
  Method coverage: 95.9% (8068 of 8408)
  Full method coverage: 88.1% (7411 of 8408)
  Covered methods: 8068
  Fully covered methods: 7411
  Total methods: 8408

PatternKit.Core                                                                                                     95.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                 98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                      92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                             93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                 96.7%
  PatternKit.Application.ServiceLayer.ServiceLayerResult<T>                                                         94.7%
  PatternKit.Application.ServiceLayer.ServiceLayerRule<T>                                                            100%
  PatternKit.Application.Specification.Specification<T>                                                              100%
  PatternKit.Application.Specification.SpecificationRegistry<T>                                                     93.3%
  PatternKit.Application.TableDataGateway.InMemoryTableDataGateway<T1, T2>                                            86%
  PatternKit.Application.TableDataGateway.TableGatewayResult<T>                                                     82.3%
  PatternKit.Application.TransactionScript.TransactionScript<T1, T2>                                                  97%
  PatternKit.Application.TransactionScript.TransactionScriptError                                                     90%
  PatternKit.Application.TransactionScript.TransactionScriptResult<T>                                                100%
  PatternKit.Application.UnitOfWork.UnitOfWork                                                                      90.9%
  PatternKit.Application.UnitOfWork.UnitOfWorkResult                                                                94.7%
  PatternKit.Application.UnitOfWork.UnitOfWorkRollbackResult                                                         100%
  PatternKit.Application.UnitOfWork.UnitOfWorkStep                                                                   100%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                         100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                    100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                              97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                    100%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the Message Bus enterprise integration pattern slice to PatternKit, including a fluent runtime API over MessageChannel<TPayload>, a source generator for topology factories, and the accompanying production-ready example + documentation/benchmark coverage updates.

Changes:

  • Introduces MessageBus<TPayload> (publish/subscribe by topic) and publish-result delivery reporting in PatternKit.Core.
  • Adds [GenerateMessageBus] + [MessageBusRoute] and a new MessageBusGenerator with diagnostics/release tracking + generator tests.
  • Adds an order message bus example (fluent + generated + DI), updates catalogs/docs, and adds BenchmarkDotNet coverage rows.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/PatternKit.Tests/Messaging/Channels/MessageBusTests.cs Adds core behavior tests for publish fan-out, rejection capture, and runtime subscriptions.
test/PatternKit.Generators.Tests/MessageBusGeneratorTests.cs Validates generator output and diagnostic IDs for the message bus generator.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Ensures new messaging attributes are covered for defaults/targets/validation.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates production-readiness pattern list/counts to include Message Bus.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs Updates expected benchmark matrix totals to account for Message Bus rows.
test/PatternKit.Examples.Tests/Messaging/OrderMessageBusExampleTests.cs Adds example coverage for fluent vs generated parity and DI import paths.
src/PatternKit.Generators/Messaging/MessageBusGenerator.cs Implements the incremental generator that emits MessageBus<TPayload> factories + diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new PKBUS diagnostics in analyzer release tracking.
src/PatternKit.Generators.Abstractions/Messaging/MessageChannelAttributes.cs Adds [GenerateMessageBus] and [MessageBusRoute] attributes.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds catalog entry wiring docs/tests/generator/example assets for Message Bus.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds example catalog descriptor for “Order Message Bus”.
src/PatternKit.Examples/Messaging/OrderMessageBusExample.cs Adds fluent + generated message bus example and DI registration helpers.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Registers the message bus example in the aggregate examples composition.
src/PatternKit.Core/Messaging/Channels/MessageChannel.cs Adds MessageBus<TPayload> plus delivery/publish result types to the core messaging surface.
README.md Updates pattern family counts and benchmark summary table to include Message Bus.
docs/patterns/messaging/README.md Adds Message Bus to the messaging patterns index.
docs/patterns/messaging/message-bus.md Adds the new pattern documentation page for Message Bus.
docs/guides/pattern-coverage.md Updates pattern coverage matrix to include Message Bus.
docs/guides/benchmark-results.md Updates benchmark results tables and published coverage totals with Message Bus rows.
docs/generators/toc.yml Adds Message Bus generator docs to the generators TOC.
docs/generators/message-bus.md Adds documentation for [GenerateMessageBus] usage and diagnostics.
docs/generators/index.md Adds Message Bus to the generator index table.
docs/examples/order-message-bus.md Adds documentation for the production-oriented Order Message Bus example.
benchmarks/PatternKit.Benchmarks/Messaging/MessageBusBenchmarks.cs Adds construction/execution benchmarks for fluent vs generated Message Bus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +64 to +69
foreach (var attr in method.GetAttributes().Where(static a => a.AttributeClass?.ToDisplayString() == "PatternKit.Generators.Messaging.MessageBusRouteAttribute"))
{
if (!method.IsStatic || !ReturnsMessageChannel(method, payloadType) || attr.ConstructorArguments.Length != 1 || attr.ConstructorArguments[0].Value is not string topic || string.IsNullOrWhiteSpace(topic))
{
context.ReportDiagnostic(Diagnostic.Create(InvalidRoute, method.Locations.FirstOrDefault(), method.Name));
continue;
@JerrettDavis
JerrettDavis merged commit 23a69f8 into main May 26, 2026
12 checks passed
@JerrettDavis
JerrettDavis deleted the feature/message-bus-pattern branch May 26, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add next enterprise integration pattern batch

2 participants